<tpl> include file='sys_config.head.html' </tpl>
<div id="doc3">
	<div id="yui-main">
		<div class="yui-g">
 			<div id="divinbox">
				<div class="gtlbar">
					<div class="gtlbar-left">预立项申请管理 &gt;&gt; 创建预立项申请</div>
				</div>
				<div class="ctge">
					<div class="ctge-1">
						<form action="project.manage.php" id="form_add" name="form_add" method="post" >
						<input type="hidden" name="action" value="save" />
						<input type="hidden" name="submit_type" id="submit_type" value="" />
						<div class="ctge-1-1">
							<table cellSpacing="0" cellPadding="0" class="fct" border="0">
								<tr>
									<th>项目名称：</th>
									<td colspan="3"><input class="fct-input" name="txtProjectName" id="txtProjectName" type="text" maxlength="50" /></td>
								</tr>
								<tr>
									<th>客户名称：</th>
									<td><input class="fct-input" name="txtCompanyName" id="txtCompanyName" type="text" value="点击选择客户" readonly="true" />
										<input class="bthl" id="selCompany" value="选择客户" type="button" />
										<input type="hidden" name="hidCompanyId" id="hidCompanyId" value="">
									</td>
									<th>客户联系人：</th>
									<td><input class="fct-input" name="txtCustomerName" id="txtCustomerName" type="text" value="点击选择联系人" readonly="true" />
										<input class="bthl" id="selCustomer" value="选择客户联系人" type="button" />
										<input type="hidden" name="hidCustomerId" id="hidCustomerId" value="">
									</td>
								</tr>
								<tr>
									<th>客户地址：</th>
									<td><input class="fct-input" name="txtCompanyAddr" id="txtCompanyAddr" type="text" value="自动载入" readonly="true" /></td>
									<th>职位头衔：</th>
									<td><input class="fct-input" name="txtCustomerJobname" id="txtCustomerJobname" type="text" value="自动载入" readonly="true" /></td>
								</tr>
								<tr>
									<th>客户网址：</th>
									<td><input class="fct-input" name="txtCompanySite" id="txtCompanySite" type="text" value="自动载入" readonly="true" /></td>
									<th>联系方式：</th>
									<td><input class="fct-input" name="txtCustomerOfficecall" id="txtCustomerOfficecall" type="text" value="自动载入" readonly="true" /></td>
								</tr>
								<tr>
									<th>比稿预计期限：</th>
									<td><input class="fct-input" readonly="true" value="<tpl> $nowDate </tpl>" name="txtDraftDate" id="txtDraftDate" type="text" /></td>
									<th>比稿预算：</th>
									<td><input class="fct-input" name="txtDraftBudget" id="txtDraftBudget" type="text" value="0.00" maxlength="13" /></td>
								</tr>
								<tr>
									<th>参与比稿人员：</th>
									<td><input class="fct-input" name="txtMemberName" id="txtMemberName" type="text" value="点击选择比稿人员" readonly="true" />
										<input class="bthl" id="selMember" value="选择比稿人员" type="button" />
										<input type="hidden" name="hidMemberId" id="hidMemberId" value="">
									</td>
									<th>选择总监：</th>
									<td><select name="txtDirectorId" id="txtDirectorId">
										<option value="1">李刚</option>
										<option value="2">王刚</option>
										<option value="3">李云龙</option>
									</select></td>
								</tr>
								<tr>
									<th>项目背景:</th>
									<td><textarea name="txtBackground" id="txtBackground" style="width:300px; height:80px;"></textarea></td>
									<th>比稿内容说明:</th>
									<td><textarea name="txtContentIntro" id="txtContentIntro" style="width:300px; height:80px;"></textarea></td>
								</tr>
								<tr>
									<th>未来项目服务内容:</th>
									<td><textarea name="txtService" id="txtService" style="width:300px; height:80px;"></textarea></td>
									<th>其他参与比稿的<br>公司简介:</th>
									<td><textarea name="txtOtherIntro" id="txtOtherIntro" style="width:300px; height:80px;"></textarea></td>
								</tr>
							</table>
						</div>
						<div class="bth-ct">
							<div class="bth-pl">
								<input class="bthl" value="保存并提交申请" type="button" onclick="submitForm('1')" />&nbsp;&nbsp;
								<input class="bthl" value="保存" type="button" onclick="submitForm('0')" />&nbsp;&nbsp;
								<input type="button" class="bthl" value="返回" onclick='history.back();'/>
							</div>
						</div>
					</form>
					</div>
				</div>	
			</div>
		</div>
	</div>
</div>
<div id="module_block" style="display:none; width:800px; height:460px; margin:0; padding:0;">
<table width="100%" border="0">
	<tr>
		<td>
			<span id="span_title" style="font-size:16px; line-height:40px;"></span>
			<div id="list_module" style="display:none"></div>
			<input type="button" value="确定" onclick="submit_module();" class="bthl" />&nbsp;&nbsp;
			<input type="button" value="取消" onclick="deleteRow(this);" class="bthl" />
		</td>
	</tr>
</table>
</div>
<tpl> include file='sys_config.js.html' </tpl>
<link href="<tpl> $site_url </tpl>/js/jquery/ui.theme.css" rel="stylesheet" type="text/css" />
<script src="<tpl> $site_url </tpl>/js/jquery/ui.datepicker.js"></script>
<script src="<tpl> $site_url </tpl>/js/jquery/jquery.blockUI.js"></script>
<script type="text/javascript">
//提交表单
function submitForm(type){
	$('#submit_type').val(type);
	$("#form_add").submit();
}
var module_block = $('#module_block')[0];
$(document).ready(function(){
	$('#txtDraftDate').datepicker({
		dateFormat:'yy-mm-dd',
		changeMonth: true,
		changeYear: true
	});
	//表单验证
	$("#form_add").validate({
		errorClass: "wrong",
		rules: {
			txtProjectName: {required:true},
			txtDraftBudget: {required:true, number:true,min: 1}
		},
		messages: {
			txtProjectName: {required: "项目名称不能为空"},
			txtDraftBudget: {required: "比稿预算不能为空", number:'比稿预算必须是数字', min:"比稿预算不能小于1"}
		}
	});
	
	$('#selCompany').click(function(e){
		$.blockUI(module_block, { width: '800px', height:'460px',top:'80px', left:'20%' });
		$('#span_title').html("选择客户");
		ajax_get_module('selCompany', 0);
		$('#list_module').slideDown("fast");
	});
	$('#selCustomer').click(function(e){
		var company_id = $("#hidCompanyId").val();
		if(company_id == ''){
			alert('请先选择客户！');
			return false;
		}
		$.blockUI(module_block, { width: '800px', height:'460px',top:'80px', left:'20%' });
		$('#span_title').html("选择客户联系人");
		ajax_get_module('selCustomer', company_id);
		$('#list_module').slideDown("fast");
	});
	$('#selMember').click(function(e){
		$.blockUI(module_block, { width: '800px', height:'460px',top:'80px', left:'20%' });
		$('#span_title').html("选择比稿人员");
		ajax_get_module('selMember', 0);
		$('#list_module').slideDown("fast");
	});
});
function ajax_get_module(str, cid){
	var idstr = '';
	if(cid != 0){
		idstr = '&cid='+cid;
	}
	$.ajax({
		url: "project.manage.php",
		data: "action=get_module&module_name="+str + idstr,
		type:'post',
		dataType:"html",
		success: function(msg){
			if(msg != ""){
				$("#list_module").html(msg);
			}else{
				//$("#list_module").html("您还没有添加客户，点击这里<a hrf='#'>添加</a>");
			}
		}
	});
	return false;
}
function deleteRow(elem) {
	$.unblockUI();
	$("#list_module").html('');
//	var row = $(elem).parent().parent();
//	row.fadeOut('normal', function() {
		//row.remove();
//	});
}
function submit_module(){
	var module_info = $('#module_info').val();
	var id = $("input[@checked]").val();
	
	if(id > 0){
		switch(module_info){
			case 'company':
				var name = $('#hidCompanyName_'+id).val();
				var addr = $('#hidAddress_'+id).val();
				var website = $('#hidWebsite_'+id).val();
				$("#hidCompanyId").val(id);
				$("#txtCompanyName").val(name);
				$("#txtCompanyAddr").val(addr);
				$("#txtCompanySite").val(website);
				break;
			case 'customer':
				var name = $('#hidCustomerName_'+id).val();
				var jobname = $('#hidCustomerJobname_'+id).val();
				var officecall = $('#hidCustomerOfficecall_'+id).val();
				$("#hidCustomerId").val(id);
				$("#txtCustomerName").val(name);
				$("#txtCustomerJobname").val(jobname);
				$("#txtCustomerOfficecall").val(officecall);
				break;
			case 'member':
				var idstr = '';
				var namestr = '';
				$("input[@checked]").each(function(){
					idstr += ',' + this.value;
					namestr += ',' + $('#mname_'+this.value).val();
				});
				if(idstr != ''){
					idstr = idstr.substr(1);
					namestr = namestr.substr(1);
				}
				//alert(idstr);
				$("#hidMemberId").val(idstr);
				$("#txtMemberName").val(namestr);
				break;
		}
	}
	
	$.unblockUI();
	$("#list_module").html('');
}
function getPageContent(address){
	$.ajax({
		url: address,
		dataType:"javascript",
		success: function(msg){
			$("#search_list").html(msg);
		}
	});
}
</script>
</body>
</html>
